﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GameSchoolWeb.Models
{

	public class CourseRepository : ICourseRepository
	{
		GameSchoolDBDataContext m_db = new GameSchoolDBDataContext();

		#region GetFunctions
		public IQueryable<Course> Courses()
		{
			return m_db.Courses;
		}

		public IQueryable<Lecture> Lecture()
		{
			return m_db.Lectures;
		}

		public IQueryable<Assignment> Assignments()
		{
			return m_db.Assignments;
		}

		public IQueryable<Comment> Comments()
		{
			return m_db.Comments;
		}

		public IQueryable<Level> Levels()
		{
			return m_db.Levels;
		}

		public IQueryable<Like> Likes()
		{
			return m_db.Likes;
		}

		public IQueryable<NewsItem> NewsItems()
		{
			return m_db.NewsItems;
		}

		public IQueryable<Exam> Exams()
		{
			return m_db.Exams;
		}

		public IQueryable<Question> Questions()
		{
			return m_db.Questions;
		}

		public IQueryable<TurninInAssignment> TurnInAssignment()
		{
			return m_db.TurninInAssignments;
		}

		public IQueryable<TurnInExam> TurnInExam()
		{
			return m_db.TurnInExams;
		}

		public IQueryable<UserRegistration> UserRegistrations()
		{
			return m_db.UserRegistrations;
		} 
		#endregion

		public void Save()
		{
			m_db.SubmitChanges();
		}

		#region PostFunctions
		public void AddCourse(Course courseItem)
		{
			m_db.Courses.InsertOnSubmit(courseItem);
		}

		public void AddUserRegistration(UserRegistration UserRegItem)
		{
			m_db.UserRegistrations.InsertOnSubmit(UserRegItem);
		}

		public void AddAssignment(Assignment assignmentItem)
		{
			m_db.Assignments.InsertOnSubmit(assignmentItem);
		}

		public void AddLevels(Level levelItem)
		{
			m_db.Levels.InsertOnSubmit(levelItem);
		}

		public void AddNews(NewsItem newsItem)
		{
			newsItem.dDateCreated = DateTime.Now;
			m_db.NewsItems.InsertOnSubmit(newsItem);
		}

		public void AddLecture(Lecture lectureItem)
		{
			m_db.Lectures.InsertOnSubmit(lectureItem);
		}

		public void AddQuestions(Question questionItem)
		{
			m_db.Questions.InsertOnSubmit(questionItem);
		}

		public void AddExam(Exam examItem)
		{
			m_db.Exams.InsertOnSubmit(examItem);
		}

		public void AddLike(Like likeItem)
		{
			m_db.Likes.InsertOnSubmit(likeItem);
		}

		public void TurnInAssignment(TurninInAssignment TurnInAssignment)
		{
			m_db.TurninInAssignments.InsertOnSubmit(TurnInAssignment);
		}

		public void AddTurnInExam(TurnInExam turnInExamItem)
		{
			m_db.TurnInExams.InsertOnSubmit(turnInExamItem);
		}

		public void AddExamTurninQuestion(ExamTurninQuestion turnInExamQuestionItem)
		{
			m_db.ExamTurninQuestions.InsertOnSubmit(turnInExamQuestionItem);
		}

		#endregion


	}
}